package org.cfg;

import com.sojoys.artifact.factory.bytebuff.IByteBuff;
import org.apache.commons.lang3.ArrayUtils;
import java.util.HashMap;
import com.sojoys.artifact.tools.SK_String;
import com.xiaoleilu.hutool.util.StrUtil;
import java.util.ArrayList;
import com.sojoys.artifact.build.data.base.BaseCfg;
import com.sojoys.artifact.tools.ToolMap;
import com.sojoys.artifact.tools.ToolCopy;
import java.util.Map;
import org.apache.commons.lang3.builder.ToStringBuilder;
import com.alibaba.fastjson.JSONObject;
import com.sojoys.artifact.constant.DataModelKeyEnum;
/**
 * 约会剧本
 */
public class DatingCfg extends BaseCfg<DatingCfg> {

	/**
	 * 数据库表名称
	 */
	public static final String TABLE_NAME = "dating";
	/**
	 * 完整类名称
	 */
	public static final String CLASS_NAME = "org.cfg.DatingCfg"; 
	/**
	 * 字段个数
	 */
	public static final int COLUMN_COUNT= 14;
	/**
	 * 数据库源字段注释
	 */
	public static final String[] SOURCE_COLUMN_REMARKS = new String[]{"","剧本号","条件类型","跳转id","事件类型","评分","可完成次数","奖励","约会类型","分支节点权重","重复奖励","结局类型","节点消耗","节点奖励",};
	/**
	 * 数据库源字段名字
	 */
	public static final String[] SOURCE_COLUMN_NAMES = new String[]{"id","scriptId","condition","jump","eventType","score","completionTimes","reward","datingType","weighting","repeatReward","endType","nodeCost","nodeReward",};
	/**
	 * 拼音字段名字
	 */
	public static final String[] PINGYING_COLUMN_NAMES = new String[]{"id","scriptId","condition","jump","eventType","score","completionTimes","reward","datingType","weighting","repeatReward","endType","nodeCost","nodeReward",};
	/**
	 * HashCode字段名字
	 */
	public static final Integer[] HASHCODE_COLUMN_NAMES = new Integer[]{3355,-407579834,-861311717,3273774,31430900,109264530,1186151626,-934326481,547188421,1338483306,1892714666,-1607227723,1122566383,1169809361,};
	/**
	 * 字段基本类型
	 */
	public static final String[] COLUMN_BASICTYPES = new String[]{"int","int","Map","int[]","int","int","int","Map","int","int","Map","int","Map","Map",};
	/**
	 * 字段引用类型
	 */
	public static final Class[] COLUMN_CLASSTYPES = new Class[]{Integer.class,Integer.class,Map.class,int[].class,Integer.class,Integer.class,Integer.class,Map.class,Integer.class,Integer.class,Map.class,Integer.class,Map.class,Map.class,};
	
	/**
	 * id
	 */
	private int id;
	
	/**
	 * 剧本号
	 */
	private int scriptId;
	
	/**
	 * 条件类型
	 */
	private Map condition;
	
	/**
	 * 跳转id
	 */
	private int[] jump;
	
	/**
	 * 事件类型
	 */
	private int eventType;
	
	/**
	 * 评分
	 */
	private int score;
	
	/**
	 * 可完成次数
	 */
	private int completionTimes;
	
	/**
	 * 奖励
	 */
	private Map reward;
	
	/**
	 * 约会类型
	 */
	private int datingType;
	
	/**
	 * 分支节点权重
	 */
	private int weighting;
	
	/**
	 * 重复奖励
	 */
	private Map repeatReward;
	
	/**
	 * 结局类型
	 */
	private int endType;
	
	/**
	 * 节点消耗
	 */
	private Map nodeCost;
	
	/**
	 * 节点奖励
	 */
	private Map nodeReward;
	
	
	
	public static DatingCfg builder() {
		DatingCfg datingCfg = new DatingCfg();
		return datingCfg;
	}
	
	/**
	 * id
	 */
	public int getId() {
		return id;
	}
	
	/**
	 * 剧本号
	 */
	public int getScriptId() {
		return scriptId;
	}
	
	/**
	 * 条件类型
	 */
	public Map getCondition() {
		return condition;
	}
	
	/**
	 * 跳转id
	 */
	public int[] getJump() {
		return jump;
	}
	
	/**
	 * 事件类型
	 */
	public int getEventType() {
		return eventType;
	}
	
	/**
	 * 评分
	 */
	public int getScore() {
		return score;
	}
	
	/**
	 * 可完成次数
	 */
	public int getCompletionTimes() {
		return completionTimes;
	}
	
	/**
	 * 奖励
	 */
	public Map getReward() {
		return reward;
	}
	
	/**
	 * 约会类型
	 */
	public int getDatingType() {
		return datingType;
	}
	
	/**
	 * 分支节点权重
	 */
	public int getWeighting() {
		return weighting;
	}
	
	/**
	 * 重复奖励
	 */
	public Map getRepeatReward() {
		return repeatReward;
	}
	
	/**
	 * 结局类型
	 */
	public int getEndType() {
		return endType;
	}
	
	/**
	 * 节点消耗
	 */
	public Map getNodeCost() {
		return nodeCost;
	}
	
	/**
	 * 节点奖励
	 */
	public Map getNodeReward() {
		return nodeReward;
	}
	
	
	protected Object[] getColumnNames(DataModelKeyEnum e){
		switch (e) {
		case SOURCE:
			return SOURCE_COLUMN_NAMES;
		case PINGYING:
			return PINGYING_COLUMN_NAMES;
		case HASHCODE:
			return HASHCODE_COLUMN_NAMES;
		case REMARKS:
			return SOURCE_COLUMN_REMARKS;
		default:
			return PINGYING_COLUMN_NAMES;
		}
	}
	
	protected String[] getBasicTypes(){
		return COLUMN_BASICTYPES;
	}
	
	protected Class[] getClassTypes(){
		return COLUMN_CLASSTYPES;
	}
	
	protected Object[] getColumeValues(){
		Object[] values = new Object[COLUMN_COUNT];
        values[0] = this.id;
        values[1] = this.scriptId;
        values[2] = this.condition;
        values[3] = this.jump;
        values[4] = this.eventType;
        values[5] = this.score;
        values[6] = this.completionTimes;
        values[7] = this.reward;
        values[8] = this.datingType;
        values[9] = this.weighting;
        values[10] = this.repeatReward;
        values[11] = this.endType;
        values[12] = this.nodeCost;
        values[13] = this.nodeReward;
        return values;
	}
	
	protected DatingCfg createColumeValues(Object[] vals) {
		this.id = (int)vals[0];
		this.scriptId = (int)vals[1];
		this.condition = (Map)vals[2];
		this.jump = (int[])vals[3];
		this.eventType = (int)vals[4];
		this.score = (int)vals[5];
		this.completionTimes = (int)vals[6];
		this.reward = (Map)vals[7];
		this.datingType = (int)vals[8];
		this.weighting = (int)vals[9];
		this.repeatReward = (Map)vals[10];
		this.endType = (int)vals[11];
		this.nodeCost = (Map)vals[12];
		this.nodeReward = (Map)vals[13];
		return this;
	}
	
	protected Map<Object, Object> toMap(Object[] keys,Map<Object, Object> map){
        map.put(keys[0], this.id);
        map.put(keys[1], this.scriptId);
        map.put(keys[2], this.condition);
        map.put(keys[3], this.jump);
        map.put(keys[4], this.eventType);
        map.put(keys[5], this.score);
        map.put(keys[6], this.completionTimes);
        map.put(keys[7], this.reward);
        map.put(keys[8], this.datingType);
        map.put(keys[9], this.weighting);
        map.put(keys[10], this.repeatReward);
        map.put(keys[11], this.endType);
        map.put(keys[12], this.nodeCost);
        map.put(keys[13], this.nodeReward);
        return map;
    }
    
    protected DatingCfg createForMap(Object[] keys,Map map){
   		this.id = (int)map.get(keys[0]);
   		this.scriptId = (int)map.get(keys[1]);
   		this.condition = (Map)map.get(keys[2]);
   		this.jump = (int[])map.get(keys[3]);
   		this.eventType = (int)map.get(keys[4]);
   		this.score = (int)map.get(keys[5]);
   		this.completionTimes = (int)map.get(keys[6]);
   		this.reward = (Map)map.get(keys[7]);
   		this.datingType = (int)map.get(keys[8]);
   		this.weighting = (int)map.get(keys[9]);
   		this.repeatReward = (Map)map.get(keys[10]);
   		this.endType = (int)map.get(keys[11]);
   		this.nodeCost = (Map)map.get(keys[12]);
   		this.nodeReward = (Map)map.get(keys[13]);
        return this;
    }
	
	
	protected JSONObject toJSONObject(Object[] keys,JSONObject obj){
        obj.put(keys[0], this.id);
        obj.put(keys[1], this.scriptId);
        obj.put(keys[2], this.condition);
        obj.put(keys[3], this.jump);
        obj.put(keys[4], this.eventType);
        obj.put(keys[5], this.score);
        obj.put(keys[6], this.completionTimes);
        obj.put(keys[7], this.reward);
        obj.put(keys[8], this.datingType);
        obj.put(keys[9], this.weighting);
        obj.put(keys[10], this.repeatReward);
        obj.put(keys[11], this.endType);
        obj.put(keys[12], this.nodeCost);
        obj.put(keys[13], this.nodeReward);
        return obj;
    }
    
    protected DatingCfg createForJSONObject(Object[] keys,JSONObject obj){
	    this.id = obj.getIntValue(keys[0]);
	    this.scriptId = obj.getIntValue(keys[1]);
		this.condition = obj.getObject(keys[2],Map.class);
		this.jump = obj.getObject(keys[3],int[].class);
	    this.eventType = obj.getIntValue(keys[4]);
	    this.score = obj.getIntValue(keys[5]);
	    this.completionTimes = obj.getIntValue(keys[6]);
		this.reward = obj.getObject(keys[7],Map.class);
	    this.datingType = obj.getIntValue(keys[8]);
	    this.weighting = obj.getIntValue(keys[9]);
		this.repeatReward = obj.getObject(keys[10],Map.class);
	    this.endType = obj.getIntValue(keys[11]);
		this.nodeCost = obj.getObject(keys[12],Map.class);
		this.nodeReward = obj.getObject(keys[13],Map.class);
        return this;
    }
    
    protected void writeBytes(IByteBuff byteBuf){
	    byteBuf.writeInt(this.id);
	    byteBuf.writeInt(this.scriptId);
	    byteBuf.writeObject(this.condition);
	    byteBuf.writeObject(this.jump);
	    byteBuf.writeInt(this.eventType);
	    byteBuf.writeInt(this.score);
	    byteBuf.writeInt(this.completionTimes);
	    byteBuf.writeObject(this.reward);
	    byteBuf.writeInt(this.datingType);
	    byteBuf.writeInt(this.weighting);
	    byteBuf.writeObject(this.repeatReward);
	    byteBuf.writeInt(this.endType);
	    byteBuf.writeObject(this.nodeCost);
	    byteBuf.writeObject(this.nodeReward);
    }
	
	protected DatingCfg readBytes(IByteBuff byteBuf){
	    this.id = byteBuf.readInt(null);
	    this.scriptId = byteBuf.readInt(null);
	    this.condition = (Map)byteBuf.readObject();
	    this.jump = byteBuf.readIntArray(null);
	    this.eventType = byteBuf.readInt(null);
	    this.score = byteBuf.readInt(null);
	    this.completionTimes = byteBuf.readInt(null);
	    this.reward = (Map)byteBuf.readObject();
	    this.datingType = byteBuf.readInt(null);
	    this.weighting = byteBuf.readInt(null);
	    this.repeatReward = (Map)byteBuf.readObject();
	    this.endType = byteBuf.readInt(null);
	    this.nodeCost = (Map)byteBuf.readObject();
	    this.nodeReward = (Map)byteBuf.readObject();
	    return this;
	}
	
	public DatingCfg deepCopy(){
		DatingCfg datingCfg = null;
		try {
			datingCfg = (DatingCfg) super.clone();
		    datingCfg.condition = ToolCopy.copyObject(this.condition);
		    datingCfg.jump = ToolCopy.copyObject(this.jump);
		    datingCfg.reward = ToolCopy.copyObject(this.reward);
		    datingCfg.repeatReward = ToolCopy.copyObject(this.repeatReward);
		    datingCfg.nodeCost = ToolCopy.copyObject(this.nodeCost);
		    datingCfg.nodeReward = ToolCopy.copyObject(this.nodeReward);
			return datingCfg;
		} catch (CloneNotSupportedException e) {
			e.printStackTrace();
		}
		return datingCfg;
	}
//自定义内容起始位置
	
	public DatingCfg(){}

	/**
	 * 剧本是否有下一节点
	 * @return
	 */
	public boolean hasNextNode() {
		return jump != null && jump.length > 0;
	}
	
	
	public void setJump(int[] ids){
		this.jump = ids;
	}
	
	//*************测试方法 开始 *************//
	public DatingCfg(int id, int[]nextids){
		this.id = id;
		this.jump = nextids;
	}
	
	public void setId(int id){
		this.id = id;
	}
	//*************测试方法 结束*************//
	
	public String toString(){
		return ToStringBuilder.reflectionToString(this);
	}
	
//自定义内容结束位置
}
